<html>
    <head>
        <title>A simple rest client</title>

        <script type="text/javascript">
            function submit() {
                var method = document.getElementById("method").value;
                var url = document.getElementById("url").value;
                var body = document.getElementById("body").value;

                var xml = new XMLHttpRequest();
                xml.open(method, url, true);
                xml.setRequestHeader('Accept', 'application/json; text/json');
                if (body) xml.setRequestHeader('Content-Type', 'application/json');

                xml.onreadystatechange = function() {
                    if (xml.readyState == 4) {
                        document.getElementById("body").value = xml.responseText;
                    }
                };
                xml.send(body);
            }
        </script>
    </head>

    <body>
        <p><select id="method">
            <option value="GET">GET</option>
            <option value="POST">POST</option>
            <option value="PUT">PUT</option>
            <option value="DELETE">DELETE</option>
            <option value="HEAD">HEAD</option>
        </select>
        <input id="url" type="text" value="http://" size="40" /></p>
        <textarea id="body" style="width: 40em; height: 200px;"></textarea>
        <p><input type="button" onclick="submit()" value="Send request" /></p>
    </body>
</html>
